﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Arizu.Repository;
using System.Data;

namespace AiRiZu.User
{
    public partial class Warnset : Common
    {
        public string Email { get; set; }
        public string PhoneNum { get; set; }

        public List<bool> EmailWarns = new List<bool>();

        public List<bool> SmsWarn = new List<bool>();


        protected void Page_Load(object sender, EventArgs e)
        {
            for (int i = 0; i < 10; i++)
            {
                EmailWarns.Add(false);
            }

            for (int i = 0; i < 10; i++)
            {
                SmsWarn.Add(false);
            }
            
            if (Session["logId"] == null)
            {
                return;
            }

            AirizuUser airizuUser = AirizuUser.CreateInstance();

            try
            {
                DataTable dt2 = airizuUser.GetUser(int.Parse(Session["logId"].ToString()));
                if (dt2.Rows.Count > 0)
                {
                    Email = dt2.Rows[0]["Email"].ToString();
                    PhoneNum = dt2.Rows[0]["MobileTelephone"].ToString();

                    string EmailNotification = dt2.Rows[0]["EmailNotification"].ToString();
                    char[] EmailNotificationChar = EmailNotification.ToCharArray();
                    for (int i = 0; i < EmailNotificationChar.Length; i++)
                    {
                        if (EmailNotificationChar[i].Equals('1'))
                        {
                            EmailWarns[i] = true;
                        }
                        else
                        {
                            EmailWarns[i] = false;
                        }
                    }

                    string SMSNotification = dt2.Rows[0]["SMSNotification"].ToString();
                    char[] SMSNotificationChar = SMSNotification.ToCharArray();
                    for (int i = 0; i < SMSNotificationChar.Length; i++)
                    {
                        if (SMSNotificationChar[i].Equals('1'))
                        {
                            SmsWarn[i] = true;
                        }
                        else
                        {
                            SmsWarn[i] = false;
                        }
                    }
                }
            }
            catch (Exception)
            {

                throw;
            }
        }
    }
}
